package org.fly.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.fly.sys.dao.SysUserMapper;
import org.fly.sys.model.SysUser;
import org.fly.sys.model.SysUserExample;
import org.fly.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author:whh
 * @date: 2025-09-16 22:39
 * <p></p>
 */
@Service
public class SysUserServiceImpl implements SysUserService {
    @Autowired
    private SysUserMapper sysUserMapper;
    @Override
    public PageInfo<SysUser> query(SysUserExample example, int pageSize, int pageNum) {
        PageHelper.startPage(pageNum,pageSize);
        List<SysUser> sysUsers = sysUserMapper.selectByExample(example);
        return new PageInfo<>(sysUsers);
    }

    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    @Override
    public int update(SysUser sysUser) {
        return sysUserMapper.updateByPrimaryKeySelective(sysUser);
    }
}
